package com.pig4cloud.pig.admin.api.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.pig4cloud.pig.common.mybatis.base.FormJson;
import com.pig4cloud.pig.common.mybatis.handler.FormJsonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 实体表
 *
 * @author pig
 * @date 2024-09-23 15:56:01
 */
@Data
@TableName("meta_entity")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "实体表")
public class MetaEntityEntity extends Model<MetaEntityEntity> {


	/**
	 * 实体id
	 */
	@TableId(type = IdType.ASSIGN_ID)
	@Schema(description = "实体id")
	private Long id;

	/**
	 * 有parent_id是子表，没有就是主表
	 */
	@Schema(description = "有parent_id是子表，没有就是主表")
	private Long parentId;

	/**
	 * 中文名
	 */
	@Schema(description = "中文名")
	@NotEmpty
	private String name;

	@Schema(description = "实体显示英文名称")
	@TableField(value = "`label`")
	@NotEmpty
	@Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]*$", message = "实体英文名称格式不正确")
	private String label;

	/**
	 * 表名
	 */
	@Schema(description = "表名")
	private String physicalName;

	/**
	 * 表单json
	 */
	@Schema(description = "表单json")
	@TableField(typeHandler = FormJsonTypeHandler.class)
	private FormJson formJson;

	/**
	 * 流程key
	 */
	@Schema(description = "流程key")
	private String flowKey;

	/**
	 * 类型，0普通表，1树表
	 */
	@Schema(description = "类型，0普通表，1树表")
	private Integer type;

	/**
	 * 是否启用流程 0关1开
	 */
	@Schema(description = "是否启用流程 0关1开")
	private String flowStatus;

	/**
	 * 添加数据时是否自动发起流程
	 */
	@Schema(description = "添加数据时是否自动发起流程0关1开")
	private String autoStartFlow;

	/**
	 * 创建人
	 */
	@TableField(fill = FieldFill.INSERT)
	@Schema(description = "创建人")
	private String createBy;

	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@Schema(description = "创建时间")
	private LocalDateTime createTime;

	/**
	 * 修改人
	 */
	@TableField(fill = FieldFill.INSERT_UPDATE)
	@Schema(description = "修改人")
	private String updateBy;

	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.INSERT_UPDATE)
	@Schema(description = "更新时间")
	private LocalDateTime updateTime;

	/**
	 * 删除标志
	 */
	@TableLogic
	@TableField(fill = FieldFill.INSERT)
	@Schema(description = "删除标志")
	private String delFlag;


	@TableField(exist = false)
	private List<MetaFieldEntity> metaFieldList;
}
